package com.unitd.frame.springweb.upload.base;

import java.io.File;
import java.util.HashMap;

/**
 * @desc 上传文件对象信息
 * @filename UploadFile.java
 * @copyright www.unitd.com
 * @author Hudan
 * @version 1.0
 * @date 2017/4/10
 */
public class UploadFile {

	/** 上传文件名称 */
	private String filename;
	/** 上传文件后缀 */
	private String suffix;
	/** 默认存放路径 */
	private String dir;
	/** 上传的源文件信息 */
	private String original;
	/** 文件类型 */
	private String type;
	/** 文件大小 */
	private long size;
	/** 文件上传的事件代码 */
	private UploadCode uploadCode;
	/** 参数信息 */
	private HashMap<String, String> paramParts;

	public UploadFile() {
		this.uploadCode = UploadCode.NORMAL;
	}

	public boolean isSuccess() {
		return UploadCode.NORMAL == this.getUploadCode();
	}

	public String getFileUrl() {
		return this.dir != null && this.filename != null ? this.dir + File.separator + this.filename : null;
	}

	public File getFile() {
		return this.dir != null && this.filename != null ? new File(this.dir + File.separator + this.filename) : null;
	}

	public boolean delFile() {
		File file = this.getFile();
		return file != null ? file.delete() : false;
	}

	public String getContentType() {
		return this.type;
	}

	public String getFilesystemName() {
		return this.filename;
	}

	public String getOriginalFileName() {
		return this.original;
	}

	public String getFilename() {
		return this.filename;
	}

	public void setFilename(String filename) {
		this.filename = filename;
	}

	public String getSuffix() {
		return this.suffix;
	}

	public void setSuffix(String suffix) {
		this.suffix = suffix;
	}

	public String getDir() {
		return this.dir;
	}

	public void setDir(String dir) {
		this.dir = dir;
	}

	public String getOriginal() {
		return this.original;
	}

	public void setOriginal(String original) {
		this.original = original;
	}

	public String getType() {
		return this.type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public long getSize() {
		return this.size;
	}

	public void setSize(long size) {
		this.size = size;
	}

	public UploadCode getUploadCode() {
		return this.uploadCode;
	}

	public void setUploadCode(UploadCode uploadCode) {
		this.uploadCode = uploadCode;
	}

	public HashMap<String, String> getParamParts() {
		return this.paramParts;
	}

	public void setParamParts(HashMap<String, String> paramParts) {
		this.paramParts = paramParts;
	}
}